<?php
    if (!defined('EXPONENT')) exit('');
    if (exponent_users_isAdmin() ||  exponent_permissions_check(array("administrate"),$loc))
    {
        $mail=null;
        $email_id=mailsystemmodule::check_email($_REQUEST['_mail_email_to']);
        if($email_id)
        {
            $content=trim($_REQUEST['_mail_content']);
            //replace url 
            $content = preg_replace(
    '/\s(href|src)=["\']?\/?(?!(http?:))([^>"\'\s]+)/i',
    ' $1="'.NONSSL_URL.'$3"',
    $content
);
                                     
            mailsystemmodule::SendMail($_REQUEST['_mail_subject'], $content, $_REQUEST['_mail_type'], $_REQUEST['_mail_email_to'], true,$user->email,$_REQUEST['_mail_email_from_name']);            
            echo 'OK';
        }
        else
            echo 'block';
        
    }
    

?>
